﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace LambdaEsxpressions
{
    public class Student
    {
        public String Name { get; set; }
        public String LastName { get; set; }
        public int Age { get; set; }

        public override string ToString()
        {
            return this.Name + " " + this.LastName + " " + this.Age;
        }
    }

    public static class Extensions
    {
        public static string ChangeFirstToCapital(this String s)
        {
            string firstLetter = (s[0] + "").ToUpper();
            string rightSide = s.Substring(1);

            string res = firstLetter + rightSide;

            return res;
        }
        public static string ChangeAllFirstLettersToCApital(this String s)
        {
            string capitalized = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s);
            return capitalized;

        }
    }

    

    class Lambdas
    {

        static Student[] students = new Student[]
        {
            new Student{ Name = "Asen" , LastName = "Baev", Age = 20},
            new Student{ Name = "Asen" , LastName = "Angelov", Age = 25},
            new Student{ Name = "Angel" , LastName = "Stoev", Age = 21},
        };

        static int[] ints = new int[]{3,7,21,28,30, 40, 60, 63};

        static void Main(string[] args)
        {

                var sorted = students.OrderBy(x => x.Name).ThenBy(x => x.LastName );
                //var divisible = ints.ToList().FindAll(x => (x % 3 == 0) && (x % 7 == 0));
                // var divisible = ints.Select(x => (x % 3 == 0) && (x % 7 == 0)); 
                
                 var div =
                    from int i in ints
                    where i % 3 == 0 && i % 7 == 0
                    select i;

                foreach (var item in sorted)
                {
                    Console.WriteLine(item);
                }

                string a = "alalala";
                a = a.ChangeFirstToCapital();
                Console.WriteLine(a);

                string sentence = " alal asjdfasd asdasd asd";
                Console.WriteLine(sentence.ChangeAllFirstLettersToCApital());
        }
    }
}
